package com.qianli.cashmama.trade.common.enums;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2017/7/31
 * Time: 下午5:27
 */
public enum TradeDiscountTypeEnum {
    COUPON(1, "优惠券"),
    REDUCTION(2, "减免");

    private int type;
    private String desc;

    TradeDiscountTypeEnum(int type, String desc) {
        this.type = type;
        this.desc = desc;
    }


    public int getType() {
        return type;
    }

    public TradeDiscountTypeEnum setType(int type) {
        this.type = type;
        return this;
    }

    public String getDesc() {
        return desc;
    }

    public TradeDiscountTypeEnum setDesc(String desc) {
        this.desc = desc;
        return this;
    }

    public static TradeDiscountTypeEnum convertByType(int type) {
        TradeDiscountTypeEnum tradeDiscountTypeEnum = null;
        for (TradeDiscountTypeEnum discountTypeEnum : TradeDiscountTypeEnum.values()) {
            if (discountTypeEnum.getType() == type) {
                tradeDiscountTypeEnum = discountTypeEnum;
                break;
            }
        }

        return tradeDiscountTypeEnum;
    }
}
